#include "signup.h"
#include "ui_signup.h"

signup::signup(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::signup)
{
    ui->setupUi(this);
}

signup::~signup()
{
    delete ui;
}

void signup::on_signinButton_clicked()
{
    QString account = ui->lineEdit_account->text();
         QString password = ui->lineEdit_password->text();
          QString id = ui->lineEdit_id->text();
          if(account.isEmpty())
          {
              QMessageBox::information(this,"提示","账号不能为空");
          }
          else if(password.isEmpty())
          {
              QMessageBox::information(this,"提示","密码不能为空");
          }
          else if(id.isEmpty())
          {
              QMessageBox::information(this,"提示","身份证不能为空");
          }
          else
    {QSqlQuery query;
            query.prepare("insert into 用户表 values(:account,:password,:id)");
            query.bindValue(":account", account);
            query.bindValue(":password", password);
            query.bindValue(":id", id);


            if (query.exec()) {
                // 注册成功
                QMessageBox::information(this,"","注册成功");
            } else {
                // 注册失败
                QMessageBox::information(this,"","账号已存在");

            }
          }
}

void signup::on_exitButton_clicked()
{
    emit sendsignal();
        this->close();
}
